package com.dsg.service.apply.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dsg.common.dto.OldCardDto;
import com.dsg.common.util.SingletonLoginUtils;
import com.dsg.entity.apply.DsgApplyCar;
import com.dsg.entity.apply.DsgApplyCard;
import com.dsg.dao.apply.DsgApplyCardMapper;
import com.dsg.entity.dto.*;
import com.dsg.service.apply.IDsgApplyCardService;
import com.dsg.service.DsgServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 油咭資料 服务实现类
 * </p>
 *
 * @author system
 * @since 2020-07-23
 */
@Service
public class DsgApplyCardServiceImpl extends DsgServiceImpl<DsgApplyCardMapper, DsgApplyCard> implements IDsgApplyCardService {

    @Override
    public IPage<ChangeCardDto> selectChangeCard(Page page, ChangeCardDto dto) {
        return baseMapper.selectChangeCard(page, dto);
    }

    @Override
    public DsgApplyCard selectReturnCardSC(String cardNo, String entCode) {
        return baseMapper.selectReturnCardSC(cardNo, entCode, SingletonLoginUtils.getSystemUserId());
    }

    @Override
    public List<ReturnCardDto> selectReturnCard(String nodeName, String cardNo, String cardFaceName, String carOilType, String carNo, Boolean isReturn, String ownsId,String cardType) {
        Integer oilType = null;
        if (carOilType != null) {
            if ("142".equals(carOilType)) {
                oilType = DsgApplyCar.CAR_OIL_TYPE_GAS;
            } else {
                oilType = DsgApplyCar.CAR_OIL_TYPE_DIESEL;
            }
        }
        return baseMapper.selectReturnCard(nodeName, cardNo, cardFaceName, oilType, carNo, isReturn, ownsId, cardType, SingletonLoginUtils.getSystemUserId());
    }

    @Override
    public DsgApplyCard getDupCardBook(DsgApplyCar car, String cardType, String cardOid) {
        return baseMapper.getDupCardBook(car, cardType, cardOid);
    }

    @Override
    public OldCardDto getOldCard(OldCardDto dto) {
        return baseMapper.getOldCard(dto);
    }

    @Override
    public DsgApplyCard getDupCardCash(DsgApplyCar car, String cardType, String cardOid) {
        return baseMapper.getDupCardCash(car, cardType, cardOid);
    }

    public List<CusCardDto> selectCusCard(CusCardSearchDto dto) {
        return baseMapper.selectCusCard(dto);
    }

    public String getOwnsIdByCardNo(String cardNo) {
        return baseMapper.getOwnsIdByCardNo(cardNo);
    }

    public List<CardRecordDto> selectCardRecord(Integer cardType, Integer appType, Integer cardStatus, Integer dedStatus, String entCode) {
        return baseMapper.selectCardRecord(cardType, appType, cardStatus, dedStatus, entCode);
    }

    @Override
    public IPage<DsgApplyCard> selectDsgApplyCard(Page page, DsgApplyCard dsgApplyCard) {
        return page.setRecords(baseMapper.selectDsgApplyCard(page, dsgApplyCard));
    }
}
